﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AppSocketModel;
using AppSocketService.Alarm;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BCGPSRESTful.Controllers.Page.Alarm
{
    /// <summary>
    /// 报警配置
    /// </summary>
    [ApiExplorerSettings(GroupName = "CompanyPage")]
    [Route("api/[controller]")]
    [ApiController]
    public class AlarmController : PageBaseController
    {
        private readonly IAlarmService alarmService;

        #region  构造函数
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="alarmService"></param>
        public AlarmController(IAlarmService alarmService)
        {
            this.alarmService = alarmService;
        }
        #endregion

        #region 设置报警配置 (根据IMEI)
        /// <summary>
        /// 设备报警配置 (根据IMEI)
        /// </summary>
        /// <param name="alarmDto"></param> 
        /// <returns></returns>
        [ProducesResponseType(typeof(bool), 200)]
        [HttpPut("[action]")]
        public ActionResult<bool> SetAlarmConfig([FromBody] AlarmDto alarmDto)
        { 
            return alarmService.SetAlarmConfig(alarmDto);
        }
        #endregion

        #region 获取报警配置
        /// <summary>
        /// 获取报警配置
        /// </summary>
        /// <param name="imei"></param>
        /// <returns></returns>
        [ProducesResponseType(typeof(AlarmDto), 200)]
        [HttpGet("[action]")]
        public ActionResult<AlarmDto> GetAlarmConfig(string imei)
        {
            return alarmService.GetAlarmConfig(imei);
        }
        #endregion
    }
}